'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform'], function($) {
  return {
    init : function(){
        
     this.initPage()
        
     this.delete()
     
     this.unstick()
      
     this.stick()
      
    },
    
    initPage: function() {
        
        $('select[name="module"]').select2({
              minimumResultsForSearch : -1,
              allowClear : true,
              width: '120'
            });
        $('select[name="module"]').change(function(){
          
          var module = $(this).children('option:selected').val();
          
          if(module != '') {
        	  window.location.href = window.__CTX__.root + "/articles?moduleId=" + module;
          } else {
        	  window.location.href = window.__CTX__.root + "/articles";
          }
          
        })
      },
    
    delete : function() {
        $(document).on('shown.bs.modal', '#article-module-delete', function(e){

            $(e.currentTarget).find("form").shiftform()
          })
      },
    
      unstick : function() {
          $(document).on('shown.bs.modal', '#activity-unstick', function(e){
    
              $(e.currentTarget).find("form").shiftform()
            })
        },
      
      stick : function() {
          $(document).on('shown.bs.modal', '#activity-stick', function(e){
    
            $(e.currentTarget).find("form").shiftform()
            })
        }
  }
})

